//
//  ByViewStarMark.m
//  chequanbao_ios
//
//  Created by pro on 17/5/9.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByViewStarMark.h"

@implementation ByViewStarMark
{
    UIImageView *_bgView;
    UIImageView *_fgView;
}

- (void)setFrameOverride:(CGRect)frame {
    
    self.frame = frame;
    
    self.height = self.width / 5;

    if (!_bgView) {
        _bgView = [[UIImageView alloc] initWithFrame:self.bounds];
        _bgView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Shops_star_dark"]];
        [self addSubview:_bgView];
    }
    if (!_fgView) {
        _fgView = [[UIImageView alloc] initWithFrame:self.bounds];
        _fgView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Shops_star_light"]];
        _fgView.hidden = YES;
        [self addSubview:_fgView];
    }
}

- (void)setupUI:(CGFloat)ratio {
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self setFrameOverride:self.frame];
        [self setRatio:ratio];
    });
}
- (void)setRatio:(CGFloat)ratio {
    
    
    _fgView.hidden = NO;
    
    _fgView.width = self.width * ratio;
}

@end
